package org.xx.armory.swing.builders;

import org.xx.armory.objectparser.LineInfo;
import org.xx.armory.objectparser.ParsedObject;

import javax.swing.*;

import static org.apache.commons.lang3.StringUtils.trimToEmpty;
import static org.xx.armory.commons.Validators.notBlank;

public final class ActionModel
        extends ParsedObject {
    private final String name;
    private final String title;
    private final char mnemonic;
    private final KeyStroke accelerator;
    private final String smallIcon;
    private final String description;
    private final String command;
    private final boolean enabled;
    private final boolean causeVerification;

    public ActionModel(
            LineInfo lineInfo,
            String name,
            String title,
            char mnemonic,
            KeyStroke accelerator,
            String smallIcon,
            String description,
            String command,
            boolean enabled,
            boolean causeVerification
    ) {
        super(lineInfo);

        this.name = notBlank(name, "name").trim();
        this.title = notBlank(title, "title").trim();
        this.mnemonic = mnemonic;
        this.accelerator = accelerator;
        this.smallIcon = trimToEmpty(smallIcon);
        this.description = trimToEmpty(description);
        this.command = trimToEmpty(command);
        this.enabled = enabled;
        this.causeVerification = causeVerification;
    }

    public final String getName() {
        return this.name;
    }

    public final String getTitle() {
        return this.title;
    }

    public final char getMnemonic() {
        return this.mnemonic;
    }

    public final KeyStroke getAccelerator() {
        return this.accelerator;
    }

    public final String getSmallIcon() {
        return this.smallIcon;
    }

    public final String getDescription() {
        return this.description;
    }

    public final String getCommand() {
        return this.command;
    }

    public final boolean isEnabled() {
        return this.enabled;
    }

    public final boolean isCauseVerification() {
        return this.causeVerification;
    }
}
